<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let num = Math.round(Math.random() * 9) + 1;
      let time = 0;
      while (true) {
        let guess = prompt("请输入数字");
        console.log(guess);
        if (guess > num) {
          alert("大啦");
        } else if (guess < num) {
          alert("小啦");
        } else {
          alert("猜对啦");
          break;
        }
        time++;
        if (time === 8  ) {
          alert("少侠请重新再来");
          break;
        }
      }
    </script>
  </body>
</html>
